package com.aspose.cells;

class zaph {
   private zcfx a;
   private zapt b;

   public zaph(zapt var1) {
      this.b = var1;
   }

   void a(zcfx var1) throws Exception {
      this.a = var1;
      var1.b("office:automatic-styles");

      int var2;
      for(var2 = 0; var2 < this.b.a.getWorksheets().getCount(); ++var2) {
         Worksheet var3 = this.b.a.getWorksheets().get(var2);
         this.a(var3);
      }

      if (this.b.k.size() > 0) {
         for(var2 = 0; var2 < this.b.k.size(); ++var2) {
            Font var4 = (Font)this.b.k.get(var2);
            this.a(var2 + 1, var4);
         }
      }

      var1.b();
   }

   private void a(Worksheet var1) throws Exception {
      PageSetup var2 = var1.getPageSetup();
      this.a.b("style:page-layout");
      this.a.a("style", "name", (String)null, "pm" + (var1.getIndex() + 1));
      this.a(var2);
      this.b(var2);
      this.c(var2);
      this.a.b();
   }

   private void a(PageSetup var1) throws Exception {
      this.a.b("style:page-layout-properties");
      if (var1.getOrientation() == 0) {
         this.a.a("style", "print-orientation", (String)null, "landscape");
      } else {
         this.a.a("style", "print-orientation", (String)null, "portrait");
      }

      double var2 = 0.0D;
      double var4 = 0.0D;
      double[] var6 = new double[]{var2};
      double[] var7 = new double[]{var4};
      zakq.a(var1, var6, var7);
      var2 = var6[0];
      var4 = var7[0];
      this.a.a("fo", "page-width", (String)null, zaqh.b(com.aspose.cells.b.a.zq.b(var2, 4)) + "in");
      this.a.a("fo", "page-height", (String)null, zaqh.b(com.aspose.cells.b.a.zq.b(var4, 4)) + "in");
      if (var1.isPercentScale()) {
         this.a.a("style", "scale-to", (String)null, zaqh.a(var1.getZoom()) + "%");
      } else {
         this.a.a("style", "scale-to-X", (String)null, zaqh.a(var1.getFitToPagesWide()));
         this.a.a("style", "scale-to-Y", (String)null, zaqh.a(var1.getFitToPagesTall()));
      }

      if (var1.getOrder() == 1) {
         this.a.a("style", "print-page-order", (String)null, "ltr");
      } else if (var1.getOrder() == 0) {
         this.a.a("style", "print-page-order", (String)null, "ttb");
      }

      this.a.a("fo", "margin-left", (String)null, zaqh.b(com.aspose.cells.b.a.zq.b(var1.getLeftMarginInch(), 4)) + "in");
      this.a.a("fo", "margin-right", (String)null, zaqh.b(com.aspose.cells.b.a.zq.b(var1.getRightMarginInch(), 4)) + "in");
      this.a.a("fo", "margin-top", (String)null, zaqh.b(com.aspose.cells.b.a.zq.b(var1.getHeaderMarginInch(), 4)) + "in");
      this.a.a("fo", "margin-bottom", (String)null, zaqh.b(com.aspose.cells.b.a.zq.b(var1.getFooterMarginInch(), 4)) + "in");
      if (var1.isAutoFirstPageNumber()) {
         this.a.a("style", "first-page-number", (String)null, "continue");
      } else {
         this.a.a("style", "first-page-number", (String)null, zaqh.a(var1.getFirstPageNumber()));
      }

      if (var1.getCenterHorizontally()) {
         if (var1.getCenterVertically()) {
            this.a.a("style", "table-centering", (String)null, "both");
         } else {
            this.a.a("style", "table-centering", (String)null, "horizontal");
         }
      } else if (var1.getCenterVertically()) {
         this.a.a("style", "table-centering", (String)null, "vertical");
      }

      StringBuilder var8 = new StringBuilder("zero-values");
      if (var1.getPrintHeadings()) {
         var8.append(" headers");
      }

      if (var1.getPrintGridlines()) {
         var8.append(" grid");
      }

      if (var1.getPrintDraft()) {
         var8.append(" charts drawings objects");
      }

      if (var1.getPrintComments() != 1) {
         var8.append(" annotations");
      }

      this.a.a("style", "print", (String)null, com.aspose.cells.b.a.zr.a(var8));
      this.a.b();
   }

   private void b(PageSetup var1) throws Exception {
      this.a.b("style:header-style");
      this.a(var1, true);
      this.a.b();
   }

   private void c(PageSetup var1) throws Exception {
      this.a.b("style:footer-style");
      this.a(var1, false);
      this.a.b();
   }

   private void a(PageSetup var1, boolean var2) throws Exception {
      this.a.b("style:header-footer-properties");
      if (var2) {
         this.a.a("fo", "min-height", (String)null, zaqh.b(com.aspose.cells.b.a.zq.b(var1.getTopMarginInch() - var1.getHeaderMarginInch(), 4)) + "in");
         this.a.a("fo", "margin-left", (String)null, "0in");
         this.a.a("fo", "margin-right", (String)null, "0in");
         this.a.a("fo", "margin-bottom", (String)null, "0in");
      } else {
         this.a.a("fo", "min-height", (String)null, zaqh.b(com.aspose.cells.b.a.zq.b(var1.getBottomMarginInch() - var1.getFooterMarginInch(), 4)) + "in");
         this.a.a("fo", "margin-left", (String)null, "0in");
         this.a.a("fo", "margin-right", (String)null, "0in");
         this.a.a("fo", "margin-top", (String)null, "0in");
      }

      this.a.b();
   }

   private void a(int var1, Font var2) throws Exception {
      this.a.b("style:style");
      this.a.a("style", "name", (String)null, "T" + var1);
      this.a.a("style", "family", (String)null, "text");
      this.a(new zapx(var2));
      this.a.b();
   }

   private void a(zapx var1) throws Exception {
      int var2 = var1.i();
      this.a.b("style:text-properties ");
      if (!zaqh.e(var1.g())) {
         this.a.a("style", "font-name", (String)null, var1.g());
         this.a.a("style", "font-name-asian", (String)null, var1.g());
      }

      if (var1.b()) {
         this.a.a("fo", "font-weight", (String)null, "bold");
         this.a.a("style", "font-weight-asian", (String)null, "bold");
         this.a.a("style", "font-weight-complex", (String)null, "bold");
      }

      if (var1.c()) {
         this.a.a("fo", "font-style", (String)null, "italic");
         this.a.a("style", "font-style-asian", (String)null, "italic");
         this.a.a("style", "font-style-complex", (String)null, "italic");
      }

      if (var1.d()) {
         this.a.a("style", "text-line-through-style", (String)null, "solid");
      }

      if (var1.h() != 0.0D) {
         this.a.a("fo", "font-size", (String)null, zaqh.a(var1.h()) + "pt");
      }

      if (!var1.a().isEmpty()) {
         String var3 = zaqh.b(var1.a());
         this.a.a("fo", "color", (String)null, var3);
      }

      if (var2 != 2 && var2 != 4) {
         if (var2 == 1 || var2 == 3) {
            this.a.a("style", "text-underline-style", (String)null, "solid");
            this.a.a("style", "text-underline-type", (String)null, "single");
         }
      } else {
         this.a.a("style", "text-underline-style", (String)null, "solid");
         this.a.a("style", "text-underline-type", (String)null, "double");
      }

      if (var1.f()) {
         this.a.a("style", "text-position", (String)null, "33% 58%");
      }

      if (var1.e()) {
         this.a.a("style", "text-position", (String)null, "-33% 58%");
      }

      this.a.b();
   }
}
